import 'package:flutter/material.dart';

//门店主要颜色 命名原则 主颜色_带透明度的16进制
mixin ColorUtils {
  ///黑色系
  static const Color black_ff262626 = Color(0xFF262626);
  static const Color black_ff555555 = Color(0xFF555555);
  static const Color black_A6000000 = Color(0xA6000000);
  static const Color blank_ff1f222a = Color(0xFF1F222A);
  static const Color black_99262626 = Color(0x99262626);

  ///灰色系
  static const Color gray_ff262626 = Color(0xFF262626);
  static const Color gray_fff5f5f5 = Color(0xFFF5F5F5);
  static const Color gray_ffe9f2ff = Color(0xFFE9F2FF);
  static const Color gray_ff999999 = Color(0xFF999999);
  static const Color gray_ff666666 = Color(0xFF666666);
  static const Color gray_ff333333 = Color(0xFF333333);
  static const Color gray_fff9f9fb = Color(0xfff9f9fb);
  static const Color gray_ffebebeb = Color(0xFFEBEBEB);
  static const Color gray_ffd9d9d9 = Color(0xFFD9D9D9);
  static const Color gray_ffbfbfbf = Color(0xFFBFBFBF);
  static const Color gray_ffeeeeee = Color(0xffeeeeee);
  static const Color gray_ffcfcfcf = Color(0xffcfcfcf);
  static const Color gray_EFEFEF = Color(0xFFEFEFEF);
  static const Color gray_EEEEEE = Color(0xFFEEEEEE);
  static const Color gray_fafafa = Color(0xFFfafafa);
  static const Color gray_ff979797 = Color(0xFF979797);
  static const Color gray_ffF7F8FC = Color(0xFFF7F8FC);
  static const Color gray_14000000 = Color(0x14000000);
  static const Color gray_fff7f7f7 = Color(0xFFF7F7F7);
  static const Color gray_0A000000 = Color(0x0A000000);
  static const Color gray_FF767C93 = Color(0xFF767C93);
  ///橙色系
  static const Color orange_fffe9600 = Color(0xFFFE9600);
  static const Color orange_14FE9600 = Color(0x14FE9600);
  static const Color orange_ffff8629 = Color(0xFFFF8629);
  static const Color orange_73ff8629 = Color(0x73FF8629); //不透明度 0.45
  static const Color orange_fffd5dd = Color(0xFFFEE5DD);
  static const Color orange_FFFFE5BF = Color(0xFFFFE5BF);
  static const Color orange_ffffd4c0 = Color(0xFFFFD4C0);
  static const Color orange_FFF4EADA = Color(0xFFF4EADA);
  static const Color orange_FFFEF8EB = Color(0xFFFEF8EB);
  static const Color orange_FFFE7F00 = Color(0xFFFE7F00);
  ///蓝色系
  static const Color blue_ff2684fe = Color(0xff2684fe);
  static const Color blue_ff0a7aff = Color(0xff0A7AFF);
  static const Color blue_ff006efe = Color(0xFF006efe);
  static const Color blue_ff006dfe = Color(0xff006DFE);
  static const Color blue_8c006dfe = Color(0x8C006DFE);
  static const Color blue_FF8CBEFE = Color(0xFF8CBEFE);
  static const Color blue_ffebf4ff = Color(0xFFEBF4FF);
  static const Color blue_73ebf4ff = Color(0x73EBF4FF); //不透明度 0.45
  static const Color blue_8cebf4ff = Color(0x8CEBF4FF);
  static const Color blue_FF006EFE = Color(0xFF006efe);
  static const Color blue_73006EFE = Color(0x73006efe); //不透明度 0.45
  static const Color blue_FFBFDBFF = Color(0xFFBFDBFF);
  static const Color blue_FFEBF4FF = Color(0xFFEBF4FF);
  static const Color blue_FFD9E9FF = Color(0xFFD9E9FF);
  static const Color blue_14006efe = Color(0x14006efe);
  static const Color blue_14cfdbec = Color(0x81CFDBEC);
  static const Color blue_ff579ffc = Color(0xff579ffc);
  static const Color blue_FF1a7cfd = Color(0xFF1a7cfd);
  static const Color blue_FF0772FD = Color(0xFF0772FD);
  static const Color blue_FFE6F1FF = Color(0xFFE6F1FF);
  static const Color blue_ff004aa0 = Color(0xFF004AA0);
  static const Color blue_ff1d2a59 = Color(0xFF1D2A59);
  static const Color blue_ffeaf3ff = Color(0xFFEAF3FF);
  static const Color blue_ff3e57fe = Color(0xFF3E57FE);
  static const Color blue_FFF5F9FF = Color(0xFFF5F9FF);
  static const Color blue_FFEBF3FF = Color(0xFFEBF3FF);
  static const Color blue_FFE4EBFC = Color(0xFFE4EBFC);
  static const Color blue_FFDFE5F3 = Color(0xFFDFE5F3);
  static const Color blue_FFD2DEF8 = Color(0xFFD2DEF8);
  static const Color blue_FFEEF6FF = Color(0xFFEEF6FF);
  static const Color blue_FFF5FAFF = Color(0xFFF5FAFF);
  static const Color blue_FF00A7FF = Color(0xFF00A7FF);
  static const Color blue_FF002280 = Color(0xFF002280);
  static const Color blue_FFF7FAFF = Color(0xFFF7FAFF);
  static const Color blue_FFD9EAFF = Color(0xFFD9EAFF);
  static const Color blue_FFDEEDFF = Color(0xFFDEEDFF);
  static const Color blue_FFF4F8FF = Color(0xFFF4F8FF);
  static const Color blue_FFDFE9F6 = Color(0xFFDFE9F6);

  ///黄色系
  static const Color yellow_ffffecd5 = Color(0xffffecd5);
  static const Color yellow_FFFFEFD9 = Color(0xffFFEFD9);
  static const Color yellow_8CFFEFD9 = Color(0x8CFFEFD9);
  static const Color yellow_FFFF8629 = Color(0xffFF8629);
  static const Color yellow_8CFF8629 = Color(0x8CFF8629);
  static const Color yellow_FFFE9600 = Color(0xFFFE9600);
  static const Color yellow_FFF9F1E5 = Color(0xFFF9F1E5);
  static const Color yellow_FFFCF1DC = Color(0xFFFCF1DC);
  static const Color yellow_FFFFFDFB = Color(0xFFFFFDFB);
  static const Color yellow_FFFFE5BF = Color(0xFFFFE5BF);
  static const Color yellow_FFFFF0D9 = Color(0xFFFFF0D9);
  static const Color yellow_FFFF00 = Colors.yellow;
  static const Color yellow_FFFDA525 = Color(0xFFFDA525);
  static const Color yellow_FFFFF7EB = Color(0xFFFFF7EB);
  static const Color yellow_FFBF913F = Color(0xFFBF913F);
  static const Color yellow_FFFFECD9 = Color(0xFFFFECD9);
  static const Color yellow_FFFE7F00 = Color(0xFFFE7F00);

  ///绿色系
  static const Color green_ffdaf4eb = Color(0xffdaf4eb);
  static const Color green_73daf4eb = Color(0x73daf4eb); //不透明度 0.45
  static const Color green_1404B177 = Color(0x1404B177);
  static const Color green_ff04b177 = Color(0xFF04B177);
  static const Color green_7304b177 = Color(0x7304B177); //不透明度 0.45
  static const Color green_ff00B179 = Color(0xFF00B179);
  static const Color green_ffebf9f5 = Color(0xffebf9f5);
  static const Color green_FFF5FCFA = Color(0xFFF5FCFA);
  static const Color green_FF04B177 = Color(0xFF04B177);
  static const Color green_FFDAF4EB = Color(0xFFDAF4EB);
  static const Color green_FFF3F9FF = Color(0xFFF3F9FF);
  static const Color green_0004B177 = Color(0x0004B177);
  static const Color green_3304B177 = Color(0x3304B177);
  static const Color green_FFC0EBDD = Color(0xFFC0EBDD);
  static const Color green_FFE5F7F1 = Color(0xFFE5F7F1);
  static const Color green_FFF7FDFB = Color(0xFFF7FDFB);
  static const Color green_FFEBF9F5 = Color(0xFFEBF9F5);
  /// 红色系
  static const Color red_fff9524b = Color(0xFFF9524B);
  static const Color red_14F9524B = Color(0x14F9524B);
  static const Color red_fffee5e4 = Color(0xFFFEE5E4);
  static const Color red_fff95851 = Color(0xFFF95851);
  static const Color red_fffff2f1 = Color(0xFFFFF2F1);
  static const Color red_fffffaf9 = Color(0xFFFFFAF9);
  static const Color red_FFF96B65 = Color(0xFFF96B65);
  static const Color red_ffFBE7E6 = Color(0xFFFBE7E6);
  static const Color red_fffff8f8 = Color(0xFFfff8f8);
  static const Color red_FFFFFDFD = Color(0xFFFFFDFD);
  static const Color red_FFFDD4D2 = Color(0xFFFDD4D2);
  static const Color red_0df9524b = Color(0x0DF9524B);
  static const Color red_FFFFF8F7 = Color(0xFFFFF8F7);
  static const Color red_FFFDDEDF = Color(0xFFFDDEDF);
  static const Color red_FFF9ECEB = Color(0xFFF9ECEB);
  static const Color red_FFFFE6E6 = Color(0xFFFFE6E6);
  static const Color red_FFFFFCFC = Color(0xFFFFFCFC);
  static const Color red_FFF40103 = Color(0xFFF40103);
  static const Color red_FFFE5E13 = Color(0xFFFE5E13);
  static const Color red_00FD8A82 = Color(0x00FD8A82);
  static const Color red_59F9524B = Color(0x59F9524B);
  static const Color red_FFFFEBEA = Color(0xFFFFEBEA);
  static const Color red_FFFD3737 = Color(0xFFFD3737);
  static const Color red_FFF5491E = Color(0xFFF5491E);
  static const Color red_FFF42B45 = Color(0xFFF42B45);

  static const Color red_FFFFF9F9 = Color(0xFFFFF9F9);
  static const Color red_FFFFF2F1 = Color(0xFFFFF2F1);
  static const Color red_FFFEF6F1 = Color(0xFFFEF6F1);
  static const Color red_FFF1E6E0 = Color(0xFFF1E6E0);
  /// 粉色系
  static const Color pink_FFFEE5E4 = Color(0xFFFEE5E4);
  static const Color pink_FFFFF2F1 = Color(0xFFFFF2F1);

  /*Colors 中已经定义的常用颜色*/
  static const Color white_ffffff = Colors.white;
  static const Color white_4dffffff = Color(0x4DFFFFFF); //不透明度 0.3
  static const Color white_73ffffff = Color(0x73FFFFFF); //不透明度 0.45
  static const Color white_A6FFFFFF = Color(0xA6FFFFFF); //不透明度 0.65
  static const Color black_000000 = Colors.black;
  static const Color black_333333 = Color(0xFF333333);
  static const Color black_7300000 = Color(0x73000000);
  static const Color orange_F9524B = Color(0xFFF9524B);
  static const Color orange_FFF0E9 = Color(0xFFFFF0E9);
  static const Color orange_73F0E9 = Color(0x73FFF0E9); //不透明度 0.45
  static const Color orange_FFE8DC = Color(0xFFFFE8DC);
  static const Color orange_F9F1E5 = Color(0xFFF9F1E5);

  /// 棕色系
  static const Color brown_FFE6B4B2 = Color(0xFFE6B4B2);
  static const Color brown_FFA37077 = Color(0xFFA37077);

  // 紫色
  static const Color purple_FF662EB4 = Color(0xFF662EB4);


  static transformColorStr(colorStr){
    // 将字符串拆分为 R, G, B A 部分
    String redStr = colorStr.substring(0, 2);
    String greenStr = colorStr.substring(2, 4);
    String blueStr = colorStr.substring(4, 6);
    String alphaStr = "FF";
    if(colorStr.length > 6){
      alphaStr = colorStr.substring(6, 8);
    }

    // 将十六进制字符串转换为整数
    int red = int.parse(redStr, radix: 16);
    int green = int.parse(greenStr, radix: 16);
    int blue = int.parse(blueStr, radix: 16);
    int alpha = int.parse(alphaStr, radix: 16);

    // 使用 Color.fromARGB() 方法创建颜色
    Color color = Color.fromARGB(alpha, red, green, blue);
    return color;
  }

  static MaterialColor createMaterialColor(Color color) {
    List list = <double>[.05];
    Map<int, Color> swatch = {};
    final int r = color.red;
    final int g = color.green;
    final int b = color.blue;
    final int a = color.alpha;
    for (int i = 1; i < 10; i++) {
      list.add(0.1 * i);
    }
    list.forEach((element) {
      final double ds = 0.5 - element;
      swatch[(element * 1000).round()] = Color.fromARGB(
          r + ((ds < 0 ? r : (255 - r)) * ds).round(),
          g + ((ds < 0 ? g : (255 - g)) * ds).round(),
          b + ((ds < 0 ? b : (255 - b)) * ds).round(),
          0
      );
    });
    return MaterialColor(color.value, swatch);
  }

  static MaterialColor createMaterialColorByColorStr(String colorStr) {
    Color color = transformColorStr(colorStr);
    return createMaterialColor(color);
  }

}
